﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>加入爱贝儿医</title>
<script src="../js/jquery.js"></script>
<link rel="stylesheet" href="../style/common.css">
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<script src="../resource/js/bootstrap.min.js"></script>
<script src="../resource/js/hermes.js"></script>
    <style>
        .error1{display: none;width:50%;margin:0 auto;position:absolute;top:80px;margin-left:25%;background: #fff;height:80px;}
        .error1 .error_delete{float:right;font:20px 黑体;color:#999;padding-bottom: 8px;margin-right:8px;}
        .error1 span{width:80%;margin:0 auto;height:80px;font:13px 黑体;color:#DA304A;display: block;}
        .add{color:#ccc}
    </style>
</head>

<body>
<?php

/**
 * Created by PhpStorm. User: ADun, Date: 14-10-15 下午10:11
 * Description:
 */
$openId=getCurrentUserOID();
if(empty($openId)) exit('参数错误');
$bm = new CUI数据中心(Page::b病历列表,$openId);
$获取短信 = $bm->生成有效链接('message',$_GET['state']);
$注册 = $bm->生成有效链接('commit',$_GET['state']);
$认证 = $bm->生成有效链接('Seller18ZiLiao',$_GET['state']);
$do=new Do用户();
if($do->get_密码()){
    header("Location:$认证");
}
?>
<div class="logo"><img src="../style/login_logo.png" /></div>
<div class="reg_form">
    <div class="line"></div>
    <div class="form_box">
        <div class="tel_icon"></div><div class="txt"><input name="tel" type="text" id="keyword" value="<?php if($_SESSION['tel']){echo $_SESSION['tel'];}else{echo "请输入手机号";};?>"onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" /></div>
    </div>
    <div class="line"></div>
    <div class="form_box">
        <div class="yzm_icon"></div><div class="txt"><input name="yanzm" type="text" id="keyword" value="请输入验证码" onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" /><div class="sent"><input name="sentyzm" type="button" value="<?php if($_SESSION['num']==null){echo "发送验证码";}else{echo "验证码已发出";};?>"><input name="" type="hidden" value="<?=$_SESSION['num']?>" /></div></div>
    </div>
    <div class="line"></div>
    <div class="big_btn" style="margin-top:20px; "><input name="" type="submit" class="red_btn" value="加入我们" /></div>
    <div class="tips"><a href="####">点击以上按钮，即表明您已同意《天使儿医用户使用协议》</a></div>
</div>
<div class="error1">
    <div class="error_delete">&times;</div>
    <div class="clear"></div>
    <span>手机号有误，请确定后重新输入！</span>
</div>
</body>
</html>

<script>
    $(function(){
        //手机验证
        $("input[name='sentyzm']").click(function(){
            var value=$("input[name='tel']").val();
            reg=/^1[3|4|5|8][0-9]\d{8}$/;
            if(!reg.test(value)){
                $(".error1").show(500);
            }else{
                num="";
                for(var i=0;i<6;i++){
                    num+=Math.floor(Math.random()*10);
                }
                $.post('<?=$获取短信?>', {'tel':value,'num':num}, function(data) {
                    location.reload();
                });

            }
        })

        var content=$("input[name='sentyzm']").val();
        if(content!="发送验证码"){
            $("input[name='sentyzm']").val("请在60s内填写");
            $("input[name='sentyzm']").attr("disabled","disabled");
            setTimeout(show(60),1000);
        }
        function show(变量) {
            $("input[name='sentyzm']").val("填写验证码("+变量+"s)");
            var now=变量-1;
            if (parseInt(变量) > 0) {
                setTimeout(function () {
                    show(now);
                }, 1000);
            } else {
                <?php $_SESSION['num']=""?>;
                $("input[name='sentyzm']").val("重新发送");
                $("input[name='sentyzm']").attr("disabled",false);
            }
        }
        $(".error_delete").click(function(){
            $(".error1").hide();
        })
        $("input[type='submit']").click(function(){
            var tel=$("input[name='tel']").val();
            var telyzm=$("input[type='hidden']").val();
            var yzm=$("input[name='yanzm']").val();
            if(telyzm){
                if(telyzm==yzm){

                    $.post('agent_manages.php?state=<?=$_GET['state']?>',{'tel':tel,'密码':yzm,'参数':'注册'},function(data){

                            <?php $_SESSION['num']=""?>;
                            <?php $_SESSION['tel']=""?>;
                            alert("注册成功");
                            window.location.href ="<?=$认证?>";
                });

                }else{
                    alert("验证码错误");
                    <?php $_SESSION['num']=""?>;
                }
            }else{
                alert("请获取验证码");
            }
        })
    })

</script>
